/**
  ******************************************************************************
  * @author     Chris
  * @since      2024/6/24 23:22
  *
  * @file       pd_spi.c
  * @brief      SPI peripheral driver.
  *
  * @note       This file contains the hardware driver for the SPI.
  *
  * @warning    None.
  ******************************************************************************
  * Change Logs:
  *   Date          Author       Notes
  *   2024/6/24     Chris        the first version
  *
  ******************************************************************************
  */


#include "pd_spi.h"
#include <assert.h>

static void SPI_init_(const SPI *this) {
    assert(0);
}

static void SPI_start_(const SPI *this, const GPIO *ssel) {
    assert(0);
}


static uint8_t SPI_swapByte_(const SPI *super, const uint8_t dat) {
    assert(0);
}

static void SPI_stop_(const SPI *this, const GPIO *ssel) {
    assert(0);
}

void SPI_constructor(SPI *this, GPIO *ssel, const uint8_t sselSize, GPIO *sclk, GPIO *mosi, GPIO *miso) {
    static struct SPIVtbl vtbl = {
        .init = &SPI_init_,
        .start = &SPI_start_,
        .swap_byte = &SPI_swapByte_,
        .stop = &SPI_stop_,
    };

    this->vptr = &vtbl;
    this->ssel = ssel;
    this->sselSize = sselSize;
    this->sclk = sclk;
    this->mosi = mosi;
    this->miso = miso;
}
